package kuzha.ast;

import java.util.ArrayList;
import java.util.List;

public class StatementList extends Statement {
	public final Statement[] body;
	
	public StatementList(Statement[] body) {
		List<Statement> bb = new ArrayList<Statement>();
		for(Statement stt: body) {
			if (stt != null && !stt.isEmpty()) {
				bb.add(stt);
			}
		}
		this.body = bb.toArray(new Statement[bb.size()]);
	}
	
	@Override
	public void accept(AstVisitor visitor) {
		visitor.visit(this);
	}
	@Override
	public <A, R> R accept(AstVisitor2<A, R> visitor, A object) {
		return visitor.visit(this, object);
	}
	
	@Override
	public boolean isEmpty() {
		return body.length == 0;
	}
}
